package com.gdth.bank.presenter;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

import com.gdth.bank.BankApplication;
import com.gdth.bank.bean.DownloadBean;
import com.gdth.bank.bean.SynchronizeBean;
import com.gdth.bank.model.DownloadModel;
import com.gdth.bank.model.DzCpKhXxPosModel;
import com.gdth.bank.view.DzCpKhXxPosView;
import com.gdth.database.bean.DaoSession;
import com.gdth.database.bean.DzCpkhXxDjPos;
import com.gdth.database.bean.TAppFjxxb;
import com.gdth.utils.GsonUtil;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;

public class DzCpKhXxPosPresenter {
	private DzCpKhXxPosView  mDzCpKhXxPosView;
	private DzCpKhXxPosModel mDzCpKhXxPosModel;
	public int loadDzCpKhXx = 101;
public DzCpKhXxPosPresenter(DzCpKhXxPosView mDzCpKhXxPosView) {
		
		this.mDzCpKhXxPosView = mDzCpKhXxPosView;
		mDzCpKhXxPosModel = new DzCpKhXxPosModel();
	}
	
	public void saveDzcpkhxxpos(DzCpkhXxDjPos mDzCpkhXxDjPos){
		mDzCpKhXxPosModel.saveDzcpkhxxpos(mDzCpkhXxDjPos)
			.subscribeOn(Schedulers.io())
			.unsubscribeOn(Schedulers.io())
			.observeOn(AndroidSchedulers.mainThread())
			.subscribe(new Subscriber<List<DzCpkhXxDjPos>>(){

				@Override
				public void onCompleted() {
					// TODO Auto-generated method stub
					/*mDzCpKhXxPosView.success();*/
				}

				@Override
				public void onError(Throwable arg0) {
					// TODO Auto-generated method stub
					mDzCpKhXxPosView.showMessage("保存本地");
				}

				@Override
				public void onNext(List<DzCpkhXxDjPos> arg0) {
					String str = GsonUtil.getGson().toJson(arg0);
					updateDzcpkhxxpos(str);
				}
				
			});
	}
	
	
	public void updateDzcpkhxxpos(String str){
		mDzCpKhXxPosView.showProgressDialog("上传POS数据");
		mDzCpKhXxPosModel.updateDzcpkhxxpos(str)
			.subscribeOn(Schedulers.io())
			.unsubscribeOn(Schedulers.io())
			.observeOn(AndroidSchedulers.mainThread())
			.subscribe(new Subscriber<String>(){

				@Override
				public void onCompleted() {
					// TODO Auto-generated method stub
					mDzCpKhXxPosView.showMessage("上传成功");
				}

				@Override
				public void onError(Throwable arg0) {
					// TODO Auto-generated method stub
					mDzCpKhXxPosView.hideProgressDialog();
					mDzCpKhXxPosView.showMessage(arg0.getMessage());
//					mDzCpKhXxPosView.success();
				}

				@Override
				public void onNext(String arg0) {
					// TODO Auto-generated method stub
					mDzCpKhXxPosView.showMessage(arg0);
					List<SynchronizeBean> beans = GsonUtil.getSynchronizeBean(arg0);
	 	   		    DaoSession session = BankApplication.getDaoSession();
	 	   		    SynchronizeBean bean =beans.get(0);
	 	      	    String 	appUuid =bean.getWybs();
	 	      	    getFjXx(appUuid);
					
					mDzCpKhXxPosModel.UpdateZtByDzpPosBySql(arg0);
					
				}
				
			});
	}
	public void  getFjXx(String appUuid){
		mDzCpKhXxPosView.showProgressDialog("上传附件");
		mDzCpKhXxPosModel.getFjXx(appUuid)
		.subscribeOn(Schedulers.io())
		.unsubscribeOn(Schedulers.io())
		.observeOn(AndroidSchedulers.mainThread())
		.subscribe(new Subscriber<List<TAppFjxxb>>(){

			@Override
			public void onCompleted() {
				// TODO Auto-generated method stub
				mDzCpKhXxPosView.hideProgressDialog();
				mDzCpKhXxPosView.showMessage("上传成功");
				mDzCpKhXxPosView.scsuccess();
				
				
			}

			@Override
			public void onError(Throwable arg0) {
				// TODO Auto-generated method stub
				mDzCpKhXxPosView.hideProgressDialog();
				mDzCpKhXxPosView.showMessage("上传失败");
				
			}

			@Override
			public void onNext(List<TAppFjxxb> arg0) {
				// TODO Auto-generated method stub
				for (TAppFjxxb mTAppFjxxb : arg0) {
					int sczt= mTAppFjxxb.getSczt();
					if(sczt==0){
					DownloadBean bean = new DownloadBean();
					bean.setName(mTAppFjxxb.getWjmc());
					bean.setWjlx(mTAppFjxxb.getWjlx());
					bean.setUuid(mTAppFjxxb.getUuid());
					bean.setWybs(mTAppFjxxb.getWybs());
					bean.setLocalPath(mTAppFjxxb.getAppdz());
					bean.setSqrsfz(mTAppFjxxb.getSfz());
					bean.setScms(0);
					bean.setCjsj(new Date());
					bean.setGnmk(3);
					bean.setZdlx(1);
					DownloadModel.getInstance().upload(bean);
					}
				}
				
			}
			
		});
	}
	public void getAllDzcpkhxxpos(String val){
		mDzCpKhXxPosModel.getAllDzcpkhxxpos(val)
		.subscribeOn(Schedulers.io())
		.unsubscribeOn(Schedulers.io())
		.observeOn(AndroidSchedulers.mainThread())
		.subscribe(new Subscriber<List<DzCpkhXxDjPos>>(){

			@Override
			public void onCompleted() {
				// TODO Auto-generated method stub
				mDzCpKhXxPosView.hideProgressDialog();
			}

			@Override
			public void onError(Throwable arg0) {
				// TODO Auto-generated method stub
				mDzCpKhXxPosView.showMessage("获取失败");
			}

			@Override
			public void onNext(List<DzCpkhXxDjPos> arg0) {
				// TODO Auto-generated method stub
				mDzCpKhXxPosView.updateListpos(arg0);
			   
			}});
	}
	public void getDzcpkhxxpos(String uuid){
		mDzCpKhXxPosModel.getDzcpkhxxpos(uuid)
		.subscribeOn(Schedulers.io())
		.unsubscribeOn(Schedulers.io())
		.observeOn(AndroidSchedulers.mainThread())
		.subscribe(new Subscriber<List<DzCpkhXxDjPos>>(){

			@Override
			public void onCompleted() {
				// TODO Auto-generated method stub
				mDzCpKhXxPosView.hideProgressDialog();
			}

			@Override
			public void onError(Throwable arg0) {
				// TODO Auto-generated method stub
				mDzCpKhXxPosView.showMessage("获取失败");
			}

			@Override
			public void onNext(List<DzCpkhXxDjPos> arg0) {
				// TODO Auto-generated method stub
				  mDzCpKhXxPosView.updateViewpos(loadDzCpKhXx, arg0);
			}});
	}
	
	 public void serachDzcpkhxxpos(String content){
		 mDzCpKhXxPosModel.serachDzcpkhxxpos(content)
 			.subscribeOn(Schedulers.io())
 			.unsubscribeOn(Schedulers.io())
 			.observeOn(AndroidSchedulers.mainThread())
 			.subscribe(new Subscriber<String>(){

 				@Override
 				public void onCompleted() {
 					// TODO Auto-generated method stub
 					
 				}
 	
 				@Override
 				public void onError(Throwable arg0) {
 					// TODO Auto-generated method stub
 					System.out.println("测试");
 					
 				}
 	
 				@Override
 				public void onNext(String arg0) {
 					// TODO Auto-generated method stub
 				//System.out.println(arg0);
 				JsonArray jsonArray = GsonUtil.getJsonArray(arg0);
 				Gson gson =GsonUtil.getGson();
	            JsonElement el = jsonArray.get(0);
	            DzCpkhXxDjPos mDzCpkhXxDjPos = gson.fromJson(el, DzCpkhXxDjPos.class);
	       		mDzCpKhXxPosView.updateViewpos(loadDzCpKhXx, mDzCpkhXxDjPos);
 				}
 		});
     }
	public void uploadDzcpkhxxpos(String uuid){
		mDzCpKhXxPosModel.getDzcpkhxxpos(uuid)
		.subscribeOn(Schedulers.io())
		.unsubscribeOn(Schedulers.io())
		.observeOn(AndroidSchedulers.mainThread())
		.subscribe(new Subscriber<List<DzCpkhXxDjPos>>(){

			@Override
			public void onCompleted() {
				// TODO Auto-generated method stub
				/*mDzCpKhXxPosView.hideProgressDialog();*/
			}

			@Override
			public void onError(Throwable arg0) {
				// TODO Auto-generated method stub
				mDzCpKhXxPosView.showMessage("获取失败");
			}

			@Override
			public void onNext(List<DzCpkhXxDjPos> arg0) {
				// TODO Auto-generated method stub
				 /* mDzCpKhXxPosView.updateViewpos(loadDzCpKhXx, arg0);*/
				String str = GsonUtil.getGson().toJson(arg0);
				updateWscDzcpkhxxpos(str);
			}});
	}
	public void updateWscDzcpkhxxpos(String str){
		mDzCpKhXxPosView.showProgressDialog("上传POS数据");
		mDzCpKhXxPosModel.updateDzcpkhxxpos(str)
			.subscribeOn(Schedulers.io())
			.unsubscribeOn(Schedulers.io())
			.observeOn(AndroidSchedulers.mainThread())
			.subscribe(new Subscriber<String>(){

				@Override
				public void onCompleted() {
					// TODO Auto-generated method stub
					mDzCpKhXxPosView.showMessage("上传成功");
				}

				@Override
				public void onError(Throwable arg0) {
					// TODO Auto-generated method stub
					mDzCpKhXxPosView.hideProgressDialog();
					mDzCpKhXxPosView.showMessage("上传失败");
				}

				@Override
				public void onNext(String arg0) {
					// TODO Auto-generated method stub
					List<SynchronizeBean> beans = GsonUtil.getSynchronizeBean(arg0);
	 	   		    DaoSession session = BankApplication.getDaoSession();
	 	   		    SynchronizeBean bean =beans.get(0);
	 	      	    String 	appUuid =bean.getWybs();
	 	      	    getFjXx(appUuid);
					
					mDzCpKhXxPosModel.UpdateZtByDzpPosBySql(arg0);
				}
				
			});
	}
	public void deleteDzcpkhxxpos(String appuuid) {
		// TODO Auto-generated method stub
		mDzCpKhXxPosModel.deleteDzcpkhxxpos(appuuid)
			.subscribeOn(Schedulers.io())
			.unsubscribeOn(Schedulers.io())
			.observeOn(AndroidSchedulers.mainThread())
			.subscribe(new Subscriber<List<DzCpkhXxDjPos>>(){

				@Override
				public void onCompleted() {
					// TODO Auto-generated method stub
					mDzCpKhXxPosView.hideProgressDialog();
				}
	
				@Override
				public void onError(Throwable arg0) {
					// TODO Auto-generated method stub
					mDzCpKhXxPosView.showMessage("获取失败");
				}
	
				@Override
				public void onNext(List<DzCpkhXxDjPos> arg0) {
					// TODO Auto-generated method stub
					/*mDzCpKhXxView.updateView(ServerUtil.server_delete, 0);*/
				}
			});
	}
	public void getAllDzcpkhxxposList(int offset,String time){
		mDzCpKhXxPosModel.getAllDzcpkhxxposList(offset,time)
		.subscribeOn(Schedulers.io())
		.unsubscribeOn(Schedulers.io())
		.observeOn(AndroidSchedulers.mainThread())
		.subscribe(new Subscriber<List<DzCpkhXxDjPos>>(){

			@Override
			public void onCompleted() {
				// TODO Auto-generated method stub
				mDzCpKhXxPosView.hideProgressDialog();
			}

			@Override
			public void onError(Throwable arg0) {
				// TODO Auto-generated method stub
				mDzCpKhXxPosView.showMessage("获取失败");
			}

			@Override
			public void onNext(List<DzCpkhXxDjPos> arg0) {
				// TODO Auto-generated method stub
				mDzCpKhXxPosView.updateListpos(arg0);
			   
			}});
	}
	
	
	public void getWcjPosListData(String content){
		mDzCpKhXxPosView.showProgressDialog("加载记录中");
		mDzCpKhXxPosModel.getWcjPosListData(content)
			.subscribeOn(Schedulers.io())
			.unsubscribeOn(Schedulers.io())
			.observeOn(AndroidSchedulers.mainThread())
			.subscribe(new Subscriber<String>(){

				@Override
				public void onCompleted() {
					// TODO Auto-generated method stub
					mDzCpKhXxPosView.hideProgressDialog();
				}
	
				@Override
				public void onError(Throwable arg0) {
					// TODO Auto-generated method stub
					mDzCpKhXxPosView.showMessage("加载失败，请检查网络设备");
					
				}
	
				@Override
				public void onNext(String arg0) {
					// TODO Auto-generated method stub
					JsonArray jsonArray = GsonUtil.getJsonArray(arg0);
 	            	Gson mGson = GsonUtil.getGson();
 	            	List<DzCpkhXxDjPos> etcList = new ArrayList<DzCpkhXxDjPos>();
 	       		    for (JsonElement el : jsonArray){
 	       		    DzCpkhXxDjPos mDzCpkhXxDjPos = mGson.fromJson(el, DzCpkhXxDjPos.class);
 	       			etcList.add(mDzCpkhXxDjPos);
 	       		    }
 	       		mDzCpKhXxPosView.updateListpos(etcList);
				}
		});
	}
	 public void getSearchPos(String content){
		 mDzCpKhXxPosView.showProgressDialog("加载记录中");
		 mDzCpKhXxPosModel.getSearchPos(content)
 			.subscribeOn(Schedulers.io())
 			.unsubscribeOn(Schedulers.io())
 			.observeOn(AndroidSchedulers.mainThread())
 			.subscribe(new Subscriber<String>(){

 				@Override
 				public void onCompleted() {
 					// TODO Auto-generated method stub
 					mDzCpKhXxPosView.hideProgressDialog();
 				}
 	
 				@Override
 				public void onError(Throwable arg0) {
 					// TODO Auto-generated method stub
 					mDzCpKhXxPosView.showMessage("加载失败");
 					
 				}
 	
 				@Override
 				public void onNext(String arg0) {
 					// TODO Auto-generated method stub
 				//System.out.println(arg0);
 				JsonArray jsonArray = GsonUtil.getJsonArray(arg0);
 				Gson gson =GsonUtil.getGson();
 				List<DzCpkhXxDjPos> mDzCpkhXxDjEtcList = new ArrayList<DzCpkhXxDjPos>();
 				for(JsonElement el : jsonArray){
 					DzCpkhXxDjPos  mDzCpkhXxDjEtc= gson.fromJson(el, DzCpkhXxDjPos.class);
 					mDzCpkhXxDjEtcList.add(mDzCpkhXxDjEtc);
 				}
 				
 				mDzCpKhXxPosView.updateListpos(mDzCpkhXxDjEtcList);
 				}
 		});
     }
	 
	 
	//未成交下拉数据刷新
		 public void getDzcpPosUpListData(String content){
			 mDzCpKhXxPosModel.getDzcpPosUpListData(content)
	 			.subscribeOn(Schedulers.io())
	 			.unsubscribeOn(Schedulers.io())
	 			.observeOn(AndroidSchedulers.mainThread())
	 			.subscribe(new Subscriber<String>(){

	 				@Override
	 				public void onCompleted() {
	 					// TODO Auto-generated method stub
	 					
	 				}
	 	
	 				@Override
	 				public void onError(Throwable arg0) {
	 					// TODO Auto-generated method stub
	 					System.out.println("测试");
	 					
	 				}
	 	
	 				@Override
	 				public void onNext(String arg0) {
	 					// TODO Auto-generated method stub
	 					JsonArray jsonArray = GsonUtil.getJsonArray(arg0);
	 	            	Gson mGson = GsonUtil.getGson();
	 	            	List<DzCpkhXxDjPos> etcList = new ArrayList<DzCpkhXxDjPos>();
	 	       		    for (JsonElement el : jsonArray){
	 	       		    DzCpkhXxDjPos mDzCpkhXxDjPos = mGson.fromJson(el, DzCpkhXxDjPos.class);
	 	       			etcList.add(mDzCpkhXxDjPos);
	 	       		    }
    	       		mDzCpKhXxPosView.updateListpos(etcList);
	 	            	
	 				}
	 		});
	     }
		
		 public void getDzcpPosOfListData(String content){
			 mDzCpKhXxPosView.showProgressDialog("加载记录中");
			 mDzCpKhXxPosModel.getDzcpPosOfListData(content)
	 			.subscribeOn(Schedulers.io())
	 			.unsubscribeOn(Schedulers.io())
	 			.observeOn(AndroidSchedulers.mainThread())
	 			.subscribe(new Subscriber<String>(){

	 				@Override
	 				public void onCompleted() {
	 					// TODO Auto-generated method stub
	 					mDzCpKhXxPosView.hideProgressDialog();
	 				}
	 	
	 				@Override
	 				public void onError(Throwable arg0) {
	 					// TODO Auto-generated method stub
	 					mDzCpKhXxPosView.showMessage("加载失败，请检查网络设备");
	 					
	 				}
	 	
	 				@Override
	 				public void onNext(String arg0) {
	 					// TODO Auto-generated method stub
	 					JsonArray jsonArray = GsonUtil.getJsonArray(arg0);
	 	            	Gson mGson = GsonUtil.getGson();
	 	            	List<DzCpkhXxDjPos> etcList = new ArrayList<DzCpkhXxDjPos>();
	 	       		    for (JsonElement el : jsonArray){
	 	       		    DzCpkhXxDjPos mDzCpkhXxDjPos = mGson.fromJson(el, DzCpkhXxDjPos.class);
	 	       			etcList.add(mDzCpkhXxDjPos);
	 	       		    }
	 	       		mDzCpKhXxPosView.updateListpos(etcList);
	 	            	
	 				}
	 		});
	     } 
		 //pos个人申报记录
		 public void getPosGeRenListData(String content){
				mDzCpKhXxPosView.showProgressDialog("加载记录中");
				mDzCpKhXxPosModel.getPosGeRenListData(content)
					.subscribeOn(Schedulers.io())
					.unsubscribeOn(Schedulers.io())
					.observeOn(AndroidSchedulers.mainThread())
					.subscribe(new Subscriber<String>(){

						@Override
						public void onCompleted() {
							// TODO Auto-generated method stub
							mDzCpKhXxPosView.hideProgressDialog();
						}
			
						@Override
						public void onError(Throwable arg0) {
							// TODO Auto-generated method stub
							mDzCpKhXxPosView.showMessage("加载失败，请检查网络设备");
							
						}
			
						@Override
						public void onNext(String arg0) {
							// TODO Auto-generated method stub
							JsonArray jsonArray = GsonUtil.getJsonArray(arg0);
		 	            	Gson mGson = GsonUtil.getGson();
		 	            	List<DzCpkhXxDjPos> etcList = new ArrayList<DzCpkhXxDjPos>();
		 	       		    for (JsonElement el : jsonArray){
		 	       		    DzCpkhXxDjPos mDzCpkhXxDjPos = mGson.fromJson(el, DzCpkhXxDjPos.class);
		 	       			etcList.add(mDzCpkhXxDjPos);
		 	       		    }
		 	       		mDzCpKhXxPosView.updateListpos(etcList);
						}
				});
			}
		 public void getDeleteDzcpPos(String appuuid) {
				// TODO Auto-generated method stub
				mDzCpKhXxPosModel.getDeleteDzcpPos(appuuid)
					.subscribeOn(Schedulers.io())
					.unsubscribeOn(Schedulers.io())
					.observeOn(AndroidSchedulers.mainThread())
					.subscribe(new Subscriber<String>(){

						@Override
						public void onCompleted() {
							// TODO Auto-generated method stub
							mDzCpKhXxPosView.hideProgressDialog();
						}
			
						@Override
						public void onError(Throwable arg0) {
							// TODO Auto-generated method stub
							mDzCpKhXxPosView.showMessage("获取失败");
						}
			
						@Override
						public void onNext(String arg0) {
							// TODO Auto-generated method stub
							mDzCpKhXxPosView.scsuccess();
						}
					});
			}
		 public void getUpDzcpPosGeRenJl(String content) {
				// TODO Auto-generated method stub
				mDzCpKhXxPosModel.getUpDzcpPosGeRenJl(content)
					.subscribeOn(Schedulers.io())
					.unsubscribeOn(Schedulers.io())
					.observeOn(AndroidSchedulers.mainThread())
					.subscribe(new Subscriber<String>(){

						@Override
						public void onCompleted() {
							// TODO Auto-generated method stub
							mDzCpKhXxPosView.hideProgressDialog();
						}
			
						@Override
						public void onError(Throwable arg0) {
							// TODO Auto-generated method stub
							mDzCpKhXxPosView.showMessage("获取失败");
						}
			
						@Override
						public void onNext(String arg0) {
							JsonArray jsonArray = GsonUtil.getJsonArray(arg0);
		 	            	Gson mGson = GsonUtil.getGson();
		 	            	List<DzCpkhXxDjPos> etcList = new ArrayList<DzCpkhXxDjPos>();
		 	       		    for (JsonElement el : jsonArray){
		 	       		    DzCpkhXxDjPos mDzCpkhXxDjPos = mGson.fromJson(el, DzCpkhXxDjPos.class);
		 	       			etcList.add(mDzCpkhXxDjPos);
		 	       		    }
		 	       		mDzCpKhXxPosView.updateListpos(etcList);
							
						}
					});
			}
		 public void getOffDzcpPosGeRenJl(String content) {
				// TODO Auto-generated method stub
				mDzCpKhXxPosModel.getOffDzcpPosGeRenJl(content)
					.subscribeOn(Schedulers.io())
					.unsubscribeOn(Schedulers.io())
					.observeOn(AndroidSchedulers.mainThread())
					.subscribe(new Subscriber<String>(){

						@Override
						public void onCompleted() {
							// TODO Auto-generated method stub
							mDzCpKhXxPosView.hideProgressDialog();
						}
			
						@Override
						public void onError(Throwable arg0) {
							// TODO Auto-generated method stub
							mDzCpKhXxPosView.showMessage("获取失败");
						}
			
						@Override
						public void onNext(String arg0) {
							JsonArray jsonArray = GsonUtil.getJsonArray(arg0);
		 	            	Gson mGson = GsonUtil.getGson();
		 	            	List<DzCpkhXxDjPos> etcList = new ArrayList<DzCpkhXxDjPos>();
		 	       		    for (JsonElement el : jsonArray){
		 	       		    DzCpkhXxDjPos mDzCpkhXxDjPos = mGson.fromJson(el, DzCpkhXxDjPos.class);
		 	       			etcList.add(mDzCpkhXxDjPos);
		 	       		    }
		 	       		mDzCpKhXxPosView.updateListpos(etcList);
							
						}
					});
			}
		 public void getSearchDzcpPosGeRenJl(String content){
			 mDzCpKhXxPosView.showProgressDialog("加载记录中");
			 mDzCpKhXxPosModel.getSearchDzcpPosGeRenJl(content)
	 			.subscribeOn(Schedulers.io())
	 			.unsubscribeOn(Schedulers.io())
	 			.observeOn(AndroidSchedulers.mainThread())
	 			.subscribe(new Subscriber<String>(){

	 				@Override
	 				public void onCompleted() {
	 					// TODO Auto-generated method stub
	 					mDzCpKhXxPosView.hideProgressDialog();
	 				}
	 	
	 				@Override
	 				public void onError(Throwable arg0) {
	 					// TODO Auto-generated method stub
	 					mDzCpKhXxPosView.showMessage("加载失败");
	 					
	 				}
	 	
	 				@Override
	 				public void onNext(String arg0) {
	 					// TODO Auto-generated method stub
	 				//System.out.println(arg0);
	 				JsonArray jsonArray = GsonUtil.getJsonArray(arg0);
	 				Gson gson =GsonUtil.getGson();
	 				List<DzCpkhXxDjPos> mDzCpkhXxDjEtcList = new ArrayList<DzCpkhXxDjPos>();
	 				for(JsonElement el : jsonArray){
	 					DzCpkhXxDjPos  mDzCpkhXxDjEtc= gson.fromJson(el, DzCpkhXxDjPos.class);
	 					mDzCpkhXxDjEtcList.add(mDzCpkhXxDjEtc);
	 				}
	 				
	 				mDzCpKhXxPosView.updateListpos(mDzCpkhXxDjEtcList);
	 				}
	 		});
	     }
		 //pos登记客户证件号校验
		 public void comparePosZjh(DzCpkhXxDjPos mDzCpkhXxDjPos){
			 mDzCpKhXxPosModel.comparePosZjh(mDzCpkhXxDjPos.getKhZjh().toString())
	 			.subscribeOn(Schedulers.io())
	 			.unsubscribeOn(Schedulers.io())
	 			.observeOn(AndroidSchedulers.mainThread())
	 			.subscribe(new Subscriber<String>(){

	 				@Override
	 				public void onCompleted() {
	 					// TODO Auto-generated method stub
	 					
	 				}
	 	
	 				@Override
	 				public void onError(Throwable arg0) {
	 					// TODO Auto-generated method stub
	 					
	 					
	 				}
	 	
	 				@Override
	 				public void onNext(String arg0) {
	 					// TODO Auto-generated method stub
	 				  String bs= arg0;
	 				 mDzCpKhXxPosView.jyZhj(bs);
	 				}
	 		});
	     }
		 //pos补录查询
		 public void searchDzcpPos(String content){
			 mDzCpKhXxPosModel.searchDzcpPos(content)
	 			.subscribeOn(Schedulers.io())
	 			.unsubscribeOn(Schedulers.io())
	 			.observeOn(AndroidSchedulers.mainThread())
	 			.subscribe(new Subscriber<String>(){

	 				@Override
	 				public void onCompleted() {
	 					// TODO Auto-generated method stub
	 					
	 				}
	 	
	 				@Override
	 				public void onError(Throwable arg0) {
	 					// TODO Auto-generated method stub
	 					
	 					
	 				}
	 	
	 				@Override
	 				public void onNext(String arg0) {
	 					// TODO Auto-generated method stub
	 				  if(arg0.equals("无此安装补录信息,请输入正确的商户号,终端号")){
	 					 mDzCpKhXxPosView.showMessage(arg0);
	 				  }else{
	 					 JsonArray jsonArray = GsonUtil.getJsonArray(arg0);
	 	 				Gson gson =GsonUtil.getGson();
	 	 				List<DzCpkhXxDjPos> mDzCpkhXxDjPosList = new ArrayList<DzCpkhXxDjPos>();
	 	 				for(JsonElement el : jsonArray){
	 	 					DzCpkhXxDjPos  mDzCpkhXxDjPos= gson.fromJson(el, DzCpkhXxDjPos.class);
	 	 					mDzCpkhXxDjPosList.add(mDzCpkhXxDjPos);
	 	 				}
	 	 				
	 					 mDzCpKhXxPosView.updateListpos(mDzCpkhXxDjPosList);
	 				  }
	 				}
	 		});
	     }
		 //pos补录查询
		 public void searchShaiXuanDzcpPos(String content){
			 mDzCpKhXxPosView.showProgressDialog("加载记录中");
			 mDzCpKhXxPosModel.searchShaiXuanDzcpPos(content)
	 			.subscribeOn(Schedulers.io())
	 			.unsubscribeOn(Schedulers.io())
	 			.observeOn(AndroidSchedulers.mainThread())
	 			.subscribe(new Subscriber<String>(){

	 				@Override
	 				public void onCompleted() {
	 					// TODO Auto-generated method stub
	 					mDzCpKhXxPosView.hideProgressDialog();
	 				}
	 	
	 				@Override
	 				public void onError(Throwable arg0) {
	 					// TODO Auto-generated method stub
	 					mDzCpKhXxPosView.showMessage(arg0.toString());
	 					
	 				}
	 	
	 				@Override
	 				public void onNext(String arg0) {
	 					// TODO Auto-generated method stub
	 					if(arg0.equals("没有此类型数据")){
	 						mDzCpKhXxPosView.showMessage("没有此类型数据");
	 					}else{
	 					 	JsonArray jsonArray = GsonUtil.getJsonArray(arg0);
	 					 	Gson gson =GsonUtil.getGson();
	 					 	List<DzCpkhXxDjPos> mDzCpkhXxDjPosList = new ArrayList<DzCpkhXxDjPos>();
	 					 	for(JsonElement el : jsonArray){
	 	 					DzCpkhXxDjPos  mDzCpkhXxDjPos= gson.fromJson(el, DzCpkhXxDjPos.class);
	 	 					mDzCpkhXxDjPosList.add(mDzCpkhXxDjPos);
	 	 				
	 	 				
	 					 mDzCpKhXxPosView.refreshData(mDzCpkhXxDjPosList);
	 				  }
	 					}
	 				}
	 		});
	     }
}

